﻿using DevelopTool.Common;
using DevelopTool.Forms.BaseForms;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using System.Windows.Forms;

namespace DevelopTool.Forms
{
    /// <summary>
    /// 主题窗体
    /// </summary>
    public partial class ThemeForm : BaseUIPage
    {
        /// <summary>
        /// 预定义颜色集合
        /// </summary>
        private readonly List<ThemItem> predefineColors = new List<ThemItem>();

        /// <summary>
        /// 中国传统颜色集合
        /// </summary>
        private readonly List<ThemItem> chineseColors = new List<ThemItem>();

        /// <summary>
        /// 颜色选择器
        /// </summary>
        private DevelopTool.Forms.CommonControls.ChoiceColorControl uIColorItem;

        public ThemeForm()
        {
            InitializeComponent();
        }

        private void ThemeForm_Load(object sender, EventArgs e)
        {
            #region 控件主题下拉框数据
            List<dynamic> dynamics = new List<dynamic>() {
                new{ Name="黑色",Type=UIMenuStyle.Black},
                new{ Name="白色",Type=UIMenuStyle.White}
            };
            cbControlThemColor.ValueMember = "Type";
            cbControlThemColor.DisplayMember = "Name";
            cbControlThemColor.DataSource = dynamics;
            cbControlThemColor.SelectedValue = Setting.Theme.ControlThemColor;
            #endregion 控件主题下拉框数据


            #region 初始化颜色选择器
            uIColorItem = new DevelopTool.Forms.CommonControls.ChoiceColorControl
            {
                Dock = DockStyle.Fill
            };
            uIColorItem.ChooseColor += UIColorItem_ChooseColor;
            this.uiPanelChooseColor.Controls.Add(uIColorItem);
            #endregion 初始化颜色选择器


            #region 字体列表加载
            InstalledFontCollection fonts = new InstalledFontCollection();
            foreach (FontFamily family in fonts.Families)
            {
                cbFont.Items.Add(family.Name);
            }
            #endregion 字体列表加载


            #region 预定义颜色加载
            predefineColors.Add(new ThemItem("蓝", UIColor.Blue));
            predefineColors.Add(new ThemItem("绿", UIColor.Green));
            predefineColors.Add(new ThemItem("红", UIColor.Red));
            predefineColors.Add(new ThemItem("灰", UIColor.Gray));
            predefineColors.Add(new ThemItem("橙", UIColor.Orange));
            predefineColors.Add(new ThemItem("Layui绿", UIColor.LayuiGreen));
            predefineColors.Add(new ThemItem("Layui红", UIColor.LayuiRed));
            predefineColors.Add(new ThemItem("Layui橙", UIColor.LayuiOrange));
            predefineColors.Add(new ThemItem("Layui灰", UIColor.LayuiCyan, UIColor.White));
            predefineColors.Add(new ThemItem("Layui蓝", UIColor.LayuiBlue, UIColor.White));
            predefineColors.Add(new ThemItem("Layui黑", UIColor.LayuiBlack, UIColor.White));
            predefineColors.Add(new ThemItem("深蓝", UIColor.DarkBlue, UIColor.White));
            predefineColors.Add(new ThemItem("黑", UIColor.Black, UIColor.White));
            predefineColors.Add(new ThemItem("紫", UIColor.Purple));
            foreach (ThemItem themItem in predefineColors)
            {
                UIButton uIButton = CreateColorButton(themItem);
                uiFlowLayoutPanelColor1.Controls.Add(uIButton);
            }

            #endregion 预定义颜色加载


            #region 中国传统颜色加载
            //红色系
            chineseColors.Add(new ThemItem("粉红", ChineseColors.红色系.粉红, "红色系", "粉红、浅红色：别称：妃色、杨妃色、湘妃色、妃红色"));
            chineseColors.Add(new ThemItem("妃色", ChineseColors.红色系.妃色, "红色系", "妃色、妃红色：古同\"绯\"，粉红色。杨妃色、湘妃色、粉红皆同义"));
            chineseColors.Add(new ThemItem("品红", ChineseColors.红色系.品红, "红色系", "品红：比大红浅的红色\n- 注：这里的\"品红\"估计是指的“一品红”，是基于大红色系的，和现在我们印刷用色的“品红M100”不是一个概念"));
            chineseColors.Add(new ThemItem("桃红", ChineseColors.红色系.桃红, "红色系", "桃红：桃花的颜色，比粉红略鲜润的颜色\n- 注：不大于M70的色彩，有时可加入适量黄色 "));
            chineseColors.Add(new ThemItem("海棠红", ChineseColors.红色系.海棠红, "红色系", "海棠红：淡紫红色、较桃红色深一些，是非常妩媚娇艳的颜色"));
            chineseColors.Add(new ThemItem("石榴红", ChineseColors.红色系.石榴红, "红色系", "石榴红：石榴花的颜色，高色度和纯度的红色"));
            chineseColors.Add(new ThemItem("樱桃色", ChineseColors.红色系.樱桃色, "红色系", "樱桃色：鲜红色"));
            chineseColors.Add(new ThemItem("银红", ChineseColors.红色系.银红, "红色系", "银红：银朱和粉红色颜料配成的颜色。多用来形容有光泽的各种红色，尤指有光泽浅红"));
            chineseColors.Add(new ThemItem("大红", ChineseColors.红色系.大红, "红色系", "大红：正红色，三原色中的红，传统的中国红，又称绛色\n- 注：RGB 色中的 R255 系列明度"));
            chineseColors.Add(new ThemItem("绛紫", ChineseColors.红色系.绛紫, "红色系", "绛紫：紫中略带红的颜色"));
            chineseColors.Add(new ThemItem("绯红", ChineseColors.红色系.绯红, "红色系", "绯红：艳丽的深红"));
            chineseColors.Add(new ThemItem("胭脂", ChineseColors.红色系.胭脂, "红色系", "1，女子装扮时用的胭脂的颜色；\n2，国画暗红色颜料"));
            chineseColors.Add(new ThemItem("朱红", ChineseColors.红色系.朱红, "红色系", "朱红：朱砂的颜色，比大红活泼，也称铅朱、朱色、丹色\n- 注：在YM对等的情况下，适量减少红色的成分就是该色的色彩系列感觉"));
            chineseColors.Add(new ThemItem("丹", ChineseColors.红色系.丹, "红色系", "丹：丹砂的鲜艳红色"));
            chineseColors.Add(new ThemItem("彤", ChineseColors.红色系.彤, "红色系", "彤：赤色"));
            chineseColors.Add(new ThemItem("茜色", ChineseColors.红色系.茜色, "红色系", "茜色：茜草染的色彩，呈深红色"));
            chineseColors.Add(new ThemItem("火红", ChineseColors.红色系.火红, "红色系", "火红：火焰的红色，赤色"));
            chineseColors.Add(new ThemItem("赫赤", ChineseColors.红色系.赫赤, "红色系", "赫赤：深红，火红。泛指赤色、火红色"));
            chineseColors.Add(new ThemItem("嫣红", ChineseColors.红色系.嫣红, "红色系", "嫣红：鲜艳的红色"));
            chineseColors.Add(new ThemItem("洋红", ChineseColors.红色系.洋红, "红色系", "洋红：色橘红\n- 注：这个色彩方向不太对，通常洋红指的是倾向于M100系列的红色，应该削弱黄色成分"));
            chineseColors.Add(new ThemItem("炎", ChineseColors.红色系.炎, "红色系", "炎：引申为红色"));
            chineseColors.Add(new ThemItem("赤", ChineseColors.红色系.赤, "红色系", "赤：本义火的颜色，即红色"));
            chineseColors.Add(new ThemItem("绾", ChineseColors.红色系.绾, "红色系", "绾：绛色；浅绛色"));
            chineseColors.Add(new ThemItem("枣红", ChineseColors.红色系.枣红, "红色系", "枣红：即深红\n- 注：色相不变，是深浅变化"));
            chineseColors.Add(new ThemItem("檀", ChineseColors.红色系.檀, "红色系", "檀：浅红色，浅绛色"));
            chineseColors.Add(new ThemItem("殷红", ChineseColors.红色系.殷红, "红色系", "殷红：发黑的红色"));
            chineseColors.Add(new ThemItem("酡红", ChineseColors.红色系.酡红, "红色系", "酡红：像饮酒后脸上泛现的红色，泛指脸红"));
            chineseColors.Add(new ThemItem("酡颜", ChineseColors.红色系.酡颜, "红色系", "酡颜：饮酒脸红的样子。亦泛指脸红色"));

            //黄色系
            chineseColors.Add(new ThemItem("鹅黄", ChineseColors.黄色系.鹅黄, "黄色系", "鹅黄：淡黄色\n- 注：鹅嘴的颜色，高明度微偏红黄色", UIColor.Black));
            chineseColors.Add(new ThemItem("鸭黄", ChineseColors.黄色系.鸭黄, "黄色系", "鸭黄：小鸭毛的黄色", UIColor.Black));
            chineseColors.Add(new ThemItem("樱草色", ChineseColors.黄色系.樱草色, "黄色系", "樱草色：淡黄色", UIColor.Black));
            chineseColors.Add(new ThemItem("杏黄", ChineseColors.黄色系.杏黄, "黄色系", "杏黄：成熟杏子的黄色\n- 注：Y100 M20~30 感觉的色彩，比较常用且有浓郁中国味道"));
            chineseColors.Add(new ThemItem("杏红", ChineseColors.黄色系.杏红, "黄色系", "杏红：成熟杏子偏红色的一种颜色"));
            chineseColors.Add(new ThemItem("橘黄", ChineseColors.黄色系.橘黄, "黄色系", "橘黄：柑橘的黄色"));
            chineseColors.Add(new ThemItem("橙黄", ChineseColors.黄色系.橙黄, "黄色系", "橙黄：橙子的黄色\n- 注：Y100 M50 感觉的色彩，现代感比较强。广告上用得较多"));
            chineseColors.Add(new ThemItem("橘红", ChineseColors.黄色系.橘红, "黄色系", "橘红：柑橘皮所呈现的红色"));
            chineseColors.Add(new ThemItem("姜黄", ChineseColors.黄色系.姜黄, "黄色系", "姜黄：中药名。别名黄姜。为姜科植物姜黄的根茎。又指人脸色不正，呈黄白色", UIColor.Black));
            chineseColors.Add(new ThemItem("缃色", ChineseColors.黄色系.缃色, "黄色系", "缃色：浅黄色"));
            chineseColors.Add(new ThemItem("橙色", ChineseColors.黄色系.橙色, "黄色系", "橙色：界于红色和黄色之间的混合色"));
            chineseColors.Add(new ThemItem("茶色", ChineseColors.黄色系.茶色, "黄色系", "茶色：一种比栗色稍红的棕橙色至浅棕色"));
            chineseColors.Add(new ThemItem("驼色", ChineseColors.黄色系.驼色, "黄色系", "驼色：一种比咔叽色稍红而微淡、比肉桂色黄而稍淡和比核桃棕色黄而暗的浅黄棕色"));
            chineseColors.Add(new ThemItem("昏黄", ChineseColors.黄色系.昏黄, "黄色系", "昏黄：形容天色、灯光等呈幽暗的黄色"));
            chineseColors.Add(new ThemItem("栗色", ChineseColors.黄色系.栗色, "黄色系", "栗色：栗壳的颜色。即紫黑色"));
            chineseColors.Add(new ThemItem("棕色", ChineseColors.黄色系.棕色, "黄色系", "棕色：棕毛的颜色，即褐色 \n1，在红色和黄色之间的任何一种颜色；\n2，适中的暗淡和适度的浅黑"));
            chineseColors.Add(new ThemItem("棕绿", ChineseColors.黄色系.棕绿, "黄色系", "棕绿：绿中泛棕色的一种颜色"));
            chineseColors.Add(new ThemItem("棕黑", ChineseColors.黄色系.棕黑, "黄色系", "棕黑：深棕色"));
            chineseColors.Add(new ThemItem("棕红", ChineseColors.黄色系.棕红, "黄色系", "棕红：红褐色"));
            chineseColors.Add(new ThemItem("棕黄", ChineseColors.黄色系.棕黄, "黄色系", "棕黄：浅褐色"));
            chineseColors.Add(new ThemItem("赭", ChineseColors.黄色系.赭, "黄色系", "赭：赤红如赭土的颜料，古人用以饰面"));
            chineseColors.Add(new ThemItem("赭色", ChineseColors.黄色系.赭色, "黄色系", "赭色：红色、赤红色"));
            chineseColors.Add(new ThemItem("琥珀", ChineseColors.黄色系.琥珀, "黄色系", "琥珀：琥珀色"));
            chineseColors.Add(new ThemItem("褐色", ChineseColors.黄色系.褐色, "黄色系", "褐色：黄黑色"));
            chineseColors.Add(new ThemItem("枯黄", ChineseColors.黄色系.枯黄, "黄色系", "枯黄：干枯焦黄"));
            chineseColors.Add(new ThemItem("黄栌", ChineseColors.黄色系.黄栌, "黄色系", "黄栌：一种落叶灌木，花黄绿色，叶子秋天变成红色。木材黄色可做染料"));
            chineseColors.Add(new ThemItem("秋色", ChineseColors.黄色系.秋色, "黄色系", "1，中常橄榄棕色,它比一般橄榄棕色稍暗,且稍稍绿些；\n2，古以秋为金,其色白,故代指白色"));
            chineseColors.Add(new ThemItem("秋香色", ChineseColors.黄色系.秋香色, "黄色系", "秋香色：浅橄榄色 浅黄绿色\n- 注：直接在Y中掺入k10~30可得到不同浓淡的该类色彩"));

            //绿色系
            chineseColors.Add(new ThemItem("嫩绿", ChineseColors.绿色系.嫩绿, "绿色系", "嫩绿：像刚长出的嫩叶的浅绿色"));
            chineseColors.Add(new ThemItem("柳黄", ChineseColors.绿色系.柳黄, "绿色系", "柳黄：像柳树芽那样的浅黄色"));
            chineseColors.Add(new ThemItem("柳绿", ChineseColors.绿色系.柳绿, "绿色系", "柳绿：柳叶的青绿色"));
            chineseColors.Add(new ThemItem("竹青", ChineseColors.绿色系.竹青, "绿色系", "竹青：竹子的绿色"));
            chineseColors.Add(new ThemItem("葱黄", ChineseColors.绿色系.葱黄, "绿色系", "葱黄：黄绿色，嫩黄色"));
            chineseColors.Add(new ThemItem("葱绿", ChineseColors.绿色系.葱绿, "绿色系", "1，浅绿又略显微黄的颜色；\n2，草木青翠的样子"));
            chineseColors.Add(new ThemItem("葱青", ChineseColors.绿色系.葱青, "绿色系", "葱青：淡淡的青绿色"));
            chineseColors.Add(new ThemItem("葱倩", ChineseColors.绿色系.葱倩, "绿色系", "葱倩：青绿色"));
            chineseColors.Add(new ThemItem("青葱", ChineseColors.绿色系.青葱, "绿色系", "青葱：翠绿色,形容植物浓绿"));
            chineseColors.Add(new ThemItem("油绿", ChineseColors.绿色系.油绿, "绿色系", "油绿：光润而浓绿的颜色。以上几种绿色都是明亮可爱的色彩"));
            chineseColors.Add(new ThemItem("绿沈", ChineseColors.绿色系.绿沈, "绿色系", "绿沈（沉）：深绿"));
            chineseColors.Add(new ThemItem("碧色", ChineseColors.绿色系.碧色, "绿色系", "1，青绿色；\n2，青白色,浅蓝色"));
            chineseColors.Add(new ThemItem("碧绿", ChineseColors.绿色系.碧绿, "绿色系", "碧绿：鲜艳的青绿色"));
            chineseColors.Add(new ThemItem("青碧", ChineseColors.绿色系.青碧, "绿色系", "青碧：鲜艳的青蓝色"));
            chineseColors.Add(new ThemItem("翡翠色", ChineseColors.绿色系.翡翠色, "绿色系", "1，翡翠鸟羽毛的青绿色；\n2，翡翠宝石的颜色\n- 注：C-Y≥30 的系列色彩，多与白色配合以体现清新明丽感觉，与黑色配合效果不好，该色个性柔弱，会被黑色牵制"));
            chineseColors.Add(new ThemItem("草绿", ChineseColors.绿色系.草绿, "绿色系", "草绿：绿而略黄的颜色"));
            chineseColors.Add(new ThemItem("青色", ChineseColors.绿色系.青色, "绿色系", "1，一类带绿的蓝色,中等深浅,高度饱和；\n2，特指三补色中的一色；\n3，本义是蓝色；\n4，一般指深绿色；\n5，也指黑色；\n6，四色印刷中的一色"));
            chineseColors.Add(new ThemItem("青翠", ChineseColors.绿色系.青翠, "绿色系", "青翠：鲜绿"));
            chineseColors.Add(new ThemItem("青白", ChineseColors.绿色系.青白, "绿色系", "青白：白而发青,尤指脸没有血色", UIColor.Black));
            chineseColors.Add(new ThemItem("鸭卵青", ChineseColors.绿色系.鸭卵青, "绿色系", "鸭卵青：淡青灰色，极淡的青绿色", UIColor.Black));
            chineseColors.Add(new ThemItem("蟹壳青", ChineseColors.绿色系.蟹壳青, "绿色系", "蟹壳青：深灰绿色"));
            chineseColors.Add(new ThemItem("鸦青", ChineseColors.绿色系.鸦青, "绿色系", "鸦青：鸦羽的颜色。即黑而带有紫绿光的颜色"));
            chineseColors.Add(new ThemItem("绿色", ChineseColors.绿色系.绿色, "绿色系", "1，在光谱中介于蓝与黄之间的那种颜色；\n2，本义：青中带黄的颜色；\n3，引申为黑色，如绿鬓：乌黑而光亮的鬓发。代指为青春年少的容颜\n- 注：现代色彩研究中，把绿色提高到了一个重要的位置，和其它红黄兰三原色并列研究，称做\"心理原色\"之一"));
            chineseColors.Add(new ThemItem("豆绿", ChineseColors.绿色系.豆绿, "绿色系", "豆绿：浅黄绿色"));
            chineseColors.Add(new ThemItem("豆青", ChineseColors.绿色系.豆青, "绿色系", "豆青：浅青绿色"));
            chineseColors.Add(new ThemItem("石青", ChineseColors.绿色系.石青, "绿色系", "石青：淡灰绿色"));
            chineseColors.Add(new ThemItem("玉色", ChineseColors.绿色系.玉色, "绿色系", "玉色：玉的颜色，高雅的淡绿、淡青色"));
            chineseColors.Add(new ThemItem("缥", ChineseColors.绿色系.缥, "绿色系", "缥：绿色而微白", UIColor.Black));
            chineseColors.Add(new ThemItem("艾绿", ChineseColors.绿色系.艾绿, "绿色系", "艾绿：艾草的颜色。偏苍白的绿色", UIColor.Black));
            chineseColors.Add(new ThemItem("松柏绿", ChineseColors.绿色系.松柏绿, "绿色系", "松柏绿：经冬松柏叶的深绿"));
            chineseColors.Add(new ThemItem("松花绿", ChineseColors.绿色系.松花绿, "绿色系", "松花绿：亦作\"松花\"、\"松绿\"。偏黑的深绿色，墨绿"));
            chineseColors.Add(new ThemItem("松花色", ChineseColors.绿色系.松花色, "绿色系", "松花色：浅黄绿色。松树花粉的颜色，《红楼梦》中提及松花配桃红为娇艳"));

            //蓝色系
            chineseColors.Add(new ThemItem("蓝", ChineseColors.蓝色系.蓝, "蓝色系", "蓝：三原色的一种。像晴天天空的颜色\n- 注：这里的蓝色指的不是RGB色彩中的B，而是CMY色彩中的C"));
            chineseColors.Add(new ThemItem("靛青", ChineseColors.蓝色系.靛青, "蓝色系", "靛青：也叫\"蓝靛\"。用蓼蓝叶泡水调和与石灰沉淀所得的蓝色染料。呈深蓝绿色\n- 注：靛，发音dian四声，有些地方将蓝墨水称为\"靛水\"或者\"兰靛水\""));
            chineseColors.Add(new ThemItem("靛蓝", ChineseColors.蓝色系.靛蓝, "蓝色系", "靛蓝：由植物(例如靛蓝或菘蓝属植物)得到的蓝色染料"));
            chineseColors.Add(new ThemItem("碧蓝", ChineseColors.蓝色系.碧蓝, "蓝色系", "碧蓝：青蓝色", UIColor.Black));
            chineseColors.Add(new ThemItem("蔚蓝", ChineseColors.蓝色系.蔚蓝, "蓝色系", "蔚蓝：类似晴朗天空的颜色的一种蓝色", UIColor.Black));
            chineseColors.Add(new ThemItem("宝蓝", ChineseColors.蓝色系.宝蓝, "蓝色系", "宝蓝：鲜艳明亮的蓝色\n- 注：英文中为 RoyalBlue 即皇家蓝色，是皇室选用的色彩，多和小面积纯黄色（金色）配合使用"));
            chineseColors.Add(new ThemItem("蓝灰色", ChineseColors.蓝色系.蓝灰色, "蓝色系", "蓝灰色：一种近于灰略带蓝的深灰色"));
            chineseColors.Add(new ThemItem("藏青", ChineseColors.蓝色系.藏青, "蓝色系", "藏青：蓝而近黑"));
            chineseColors.Add(new ThemItem("藏蓝", ChineseColors.蓝色系.藏蓝, "蓝色系", "藏蓝：蓝里略透红色"));
            chineseColors.Add(new ThemItem("黛", ChineseColors.蓝色系.黛, "蓝色系", "黛：青黑色的颜料。古代女子用以画眉"));
            chineseColors.Add(new ThemItem("黛螺", ChineseColors.蓝色系.黛螺, "蓝色系", "黛螺：绘画或画眉所使用的青黑色颜料，代指女子眉妩"));
            chineseColors.Add(new ThemItem("黛色", ChineseColors.蓝色系.黛色, "蓝色系", "黛色：青黑色。"));
            chineseColors.Add(new ThemItem("黛绿", ChineseColors.蓝色系.黛绿, "蓝色系", "黛绿：墨绿"));
            chineseColors.Add(new ThemItem("黛蓝", ChineseColors.蓝色系.黛蓝, "蓝色系", "黛蓝：深蓝色"));
            chineseColors.Add(new ThemItem("黛紫", ChineseColors.蓝色系.黛紫, "蓝色系", "黛紫：深紫色"));
            chineseColors.Add(new ThemItem("紫色", ChineseColors.蓝色系.紫色, "蓝色系", "紫色：蓝和红组成的颜色。古人以紫为祥瑞的颜色。代指与帝王、皇宫有关的事物"));
            chineseColors.Add(new ThemItem("紫酱", ChineseColors.蓝色系.紫酱, "蓝色系", "紫酱：浑浊的紫色"));
            chineseColors.Add(new ThemItem("酱紫", ChineseColors.蓝色系.酱紫, "蓝色系", "酱紫：紫中略带红的颜色"));
            chineseColors.Add(new ThemItem("紫檀", ChineseColors.蓝色系.紫檀, "蓝色系", "紫檀：檀木的颜色，也称乌檀色、乌木色"));
            chineseColors.Add(new ThemItem("绀青", ChineseColors.蓝色系.绀青, "蓝色系", "绀青 绀紫：纯度较低的深紫色"));
            chineseColors.Add(new ThemItem("紫棠", ChineseColors.蓝色系.紫棠, "蓝色系", "紫棠：黑红色"));
            chineseColors.Add(new ThemItem("青莲", ChineseColors.蓝色系.青莲, "蓝色系", "青莲：偏蓝的紫色"));
            chineseColors.Add(new ThemItem("群青", ChineseColors.蓝色系.群青, "蓝色系", "群青：深蓝色"));
            chineseColors.Add(new ThemItem("雪青", ChineseColors.蓝色系.雪青, "蓝色系", "雪青：浅蓝紫色"));
            chineseColors.Add(new ThemItem("丁香色", ChineseColors.蓝色系.丁香色, "蓝色系", "丁香色：紫丁香的颜色，浅浅的紫色，很娇柔淡雅的色彩"));
            chineseColors.Add(new ThemItem("藕色", ChineseColors.蓝色系.藕色, "蓝色系", "藕色：浅灰而略带红的颜色", UIColor.Black));
            chineseColors.Add(new ThemItem("藕荷色", ChineseColors.蓝色系.藕荷色, "蓝色系", "藕荷色：浅紫而略带红的颜色", UIColor.Black));

            //苍色系
            chineseColors.Add(new ThemItem("苍色", ChineseColors.苍色系.苍色, "苍色系", "苍色：即各种颜色掺入黑色后的颜色"));
            chineseColors.Add(new ThemItem("苍翠", ChineseColors.苍色系.苍翠, "苍色系", "苍翠"));
            chineseColors.Add(new ThemItem("苍黄", ChineseColors.苍色系.苍黄, "苍色系", "苍黄"));
            chineseColors.Add(new ThemItem("苍青", ChineseColors.苍色系.苍青, "苍色系", "苍青"));
            chineseColors.Add(new ThemItem("苍黑", ChineseColors.苍色系.苍黑, "苍色系", "苍黑"));
            chineseColors.Add(new ThemItem("苍白", ChineseColors.苍色系.苍白, "苍色系", "苍白\n- 注：准确的说是掺入不同灰度级别的灰色", UIColor.Black));

            //水色系
            chineseColors.Add(new ThemItem("水色", ChineseColors.水色系.水色, "水色系", "水色", UIColor.Black));
            chineseColors.Add(new ThemItem("水红", ChineseColors.水色系.水红, "水色系", "水红", UIColor.Black));
            chineseColors.Add(new ThemItem("水绿", ChineseColors.水色系.水绿, "水色系", "水绿", UIColor.Black));
            chineseColors.Add(new ThemItem("水蓝", ChineseColors.水色系.水蓝, "水色系", "水蓝", UIColor.Black));
            chineseColors.Add(new ThemItem("淡青", ChineseColors.水色系.淡青, "水色系", "淡青", UIColor.Black));
            chineseColors.Add(new ThemItem("湖蓝", ChineseColors.水色系.湖蓝, "水色系", "湖蓝", UIColor.Black));
            chineseColors.Add(new ThemItem("湖绿", ChineseColors.水色系.湖绿, "水色系", "湖绿，皆是浅色。深色淡色：颜色深的或浅的，不再一一列出", UIColor.Black));

            //灰白色系
            chineseColors.Add(new ThemItem("精白", ChineseColors.灰白色系.精白, "灰白色系", "精白：纯白，洁白，净白，粉白", UIColor.Black));
            chineseColors.Add(new ThemItem("象牙白", ChineseColors.灰白色系.象牙白, "灰白色系", "象牙白：乳白色", UIColor.Black));
            chineseColors.Add(new ThemItem("雪白", ChineseColors.灰白色系.雪白, "灰白色系", "雪白：如雪般洁白", UIColor.Black));
            chineseColors.Add(new ThemItem("月白", ChineseColors.灰白色系.月白, "灰白色系", "月白：淡蓝色", UIColor.Black));
            chineseColors.Add(new ThemItem("缟", ChineseColors.灰白色系.缟, "灰白色系", "缟：白色", UIColor.Black));
            chineseColors.Add(new ThemItem("素", ChineseColors.灰白色系.素, "灰白色系", "素：白色，无色", UIColor.Black));
            chineseColors.Add(new ThemItem("荼白", ChineseColors.灰白色系.荼白, "灰白色系", "荼白：如荼之白色", UIColor.Black));
            chineseColors.Add(new ThemItem("霜色", ChineseColors.灰白色系.霜色, "灰白色系", "霜色：白霜的颜色", UIColor.Black));
            chineseColors.Add(new ThemItem("花白", ChineseColors.灰白色系.花白, "灰白色系", "花白：白色和黑色混杂的。斑白的 夹杂有灰色的白", UIColor.Black));
            chineseColors.Add(new ThemItem("鱼肚白", ChineseColors.灰白色系.鱼肚白, "灰白色系", "鱼肚白：似鱼腹部的颜色，多指黎明时东方的天色颜色\n- 注：M5 Y5", UIColor.Black));
            chineseColors.Add(new ThemItem("莹白", ChineseColors.灰白色系.莹白, "灰白色系", "莹白：晶莹洁白", UIColor.Black));
            chineseColors.Add(new ThemItem("灰色", ChineseColors.灰白色系.灰色, "灰白色系", "灰色：黑色和白色混和成的一种颜色"));
            chineseColors.Add(new ThemItem("牙色", ChineseColors.灰白色系.牙色, "灰白色系", "牙色：与象牙相似的淡黄色\n- 注：暖白", UIColor.Black));
            chineseColors.Add(new ThemItem("铅白", ChineseColors.灰白色系.铅白, "灰白色系", "铅白：铅粉的白色。铅粉，国画颜料，日久易氧化\"返铅\"变黑。铅粉在古时用以搽脸的化妆品\n- 注：冷白", UIColor.Black));

            //黑色系
            chineseColors.Add(new ThemItem("玄色", ChineseColors.黑色系.玄色, "黑色系", "玄色：赤黑色，黑中带红的颜色，又泛指黑色"));
            chineseColors.Add(new ThemItem("玄青", ChineseColors.黑色系.玄青, "黑色系", "玄青：深黑色"));
            chineseColors.Add(new ThemItem("乌色", ChineseColors.黑色系.乌色, "黑色系", "乌色：暗而呈黑的颜色"));
            chineseColors.Add(new ThemItem("乌黑", ChineseColors.黑色系.乌黑, "黑色系", "乌黑：深黑；漆黑"));
            chineseColors.Add(new ThemItem("漆黑", ChineseColors.黑色系.漆黑, "黑色系", "漆黑：非常黑的"));
            chineseColors.Add(new ThemItem("墨色", ChineseColors.黑色系.墨色, "黑色系", "墨色：即黑色"));
            chineseColors.Add(new ThemItem("墨灰", ChineseColors.黑色系.墨灰, "黑色系", "墨灰：即黑灰"));
            chineseColors.Add(new ThemItem("黑色", ChineseColors.黑色系.黑色, "黑色系", "黑色：亮度最低的非彩色的或消色差的物体的颜色；最暗的灰色；\n与白色截然不同的消色差的颜色；\n被认为特别属于那些既不能反射、又不能透过能使人感觉到的微小入射光的物体，任何亮度很低的物体颜色"));
            chineseColors.Add(new ThemItem("缁色", ChineseColors.黑色系.缁色, "黑色系", "缁色：帛黑色"));
            chineseColors.Add(new ThemItem("煤黑", ChineseColors.黑色系.煤黑, "黑色系", "煤黑、象牙黑：都是黑，不过有冷暖之分"));
            chineseColors.Add(new ThemItem("黧", ChineseColors.黑色系.黧, "黑色系", "黧：黑中带黄的颜色"));
            chineseColors.Add(new ThemItem("黎", ChineseColors.黑色系.黎, "黑色系", "黎：黑中带黄似黎草色"));
            chineseColors.Add(new ThemItem("黝", ChineseColors.黑色系.黝, "黑色系", "黝：本义为淡黑色或微青黑色"));
            chineseColors.Add(new ThemItem("黝黑", ChineseColors.黑色系.黝黑, "黑色系", "黝黑：皮肤暴露在太阳光下而晒成的，青黑色"));
            chineseColors.Add(new ThemItem("黯", ChineseColors.黑色系.黯, "黑色系", "黯：深黑色、泛指黑色"));

            //金银色系
            chineseColors.Add(new ThemItem("赤金", ChineseColors.金银色系.赤金, "金银色系", "赤金：足金的颜色"));
            chineseColors.Add(new ThemItem("金色", ChineseColors.金银色系.金色, "金银色系", "金色：平均为深黄色带光泽的颜色"));
            chineseColors.Add(new ThemItem("银白", ChineseColors.金银色系.银白, "金银色系", "银白：带银光的白色", UIColor.Black));
            chineseColors.Add(new ThemItem("铜绿", ChineseColors.金银色系.铜绿, "金银色系", "铜绿"));
            chineseColors.Add(new ThemItem("乌金", ChineseColors.金银色系.乌金, "金银色系", "乌金"));
            chineseColors.Add(new ThemItem("老银", ChineseColors.金银色系.老银, "金银色系", "老银：金属氧化后的色彩", UIColor.Black));

            var sortedListAscending = chineseColors.OrderBy(it => it.BackColor.GetBrightness());

            foreach (ThemItem themItem in sortedListAscending)
            {
                TabPage tabPage = uiTabControlMenuChineseColor.TabPages.Cast<TabPage>().FirstOrDefault(it => it.Text == themItem.Group);
                UIFlowLayoutPanel uIFlowLayoutPanel = null;
                if (tabPage == null)
                {
                    tabPage = new TabPage(themItem.Group);
                    uiTabControlMenuChineseColor.TabPages.Add(tabPage);
                    uIFlowLayoutPanel = new UIFlowLayoutPanel
                    {
                        Dock = DockStyle.Fill
                    };
                    tabPage.Controls.Add(uIFlowLayoutPanel);
                }
                else
                {
                    uIFlowLayoutPanel = tabPage.Controls[0] as UIFlowLayoutPanel;
                }

                UIButton uIButton = CreateColorButton(themItem);
                uIFlowLayoutPanel.Controls.Add(uIButton);

            }

            #endregion 中国传统颜色加载

            //从配置文件读取，设置颜色选择器的颜色            
            this.uIColorItem.SelectedColor = Setting.Theme.BackColor;
            this.uiColorPickerForeColor.Value = Setting.Theme.ForeColor;
            this.cbFont.SelectedItem = Setting.Theme.FontFamily;
            this.uiTrackBarFontScale.Value = Setting.Theme.FontSize;
            this.lblFontScale.Text = Setting.Theme.FontSize.ToString();

            //窗口大小文本框值设置
            this.txtWindowsWidth.IntValue = GlobalData.MainForm.Width;
            this.txtWindowsHeight.IntValue = GlobalData.MainForm.Height;

            #region 显示动画
            //AnimatorHelper.BindShowAnimator(new List<Control>() {
            //        { this.uiTabControl1},
            //    });

            #endregion 显示动画
        }

        private UIButton CreateColorButton(ThemItem themItem)
        {
            UIButton uIButton = new UIButton()
            {
                Text = themItem.ColorName,
                FillColor = themItem.BackColor,
                FillColor2 = themItem.BackColor,
                FillHoverColor = themItem.BackColor,
                FillPressColor = themItem.BackColor,
                FillSelectedColor = themItem.BackColor,
                RectColor = themItem.BackColor,
                RectHoverColor = themItem.BackColor,
                RectPressColor = themItem.BackColor,
                RectSelectedColor = themItem.BackColor,
                TipsColor = themItem.BackColor,
                Size = this.btnRandomColor.Size,//跟随“随机颜色切换”按钮尺寸
                Style = Sunny.UI.UIStyle.Custom,//自定义颜色，不跟随系统主题色改变
                Tag = themItem,
                ForeColor = themItem.ForeColor,
            };
            uIButton.MouseLeave += UIButton_MouseLeave;
            uIButton.MouseEnter += UIButton_MouseEnter;
            uIButton.MouseClick += UIButton_MouseClick;
            uiToolTip1.SetToolTip(uIButton, themItem.Tips ?? " ", $"Name={themItem.BackColor.Name},ARGB={themItem.BackColor}", 61530, 35, themItem.BackColor);
            return uIButton;

            
        }

        /// <summary>
        /// 自定义颜色选择事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="color"></param>
        private void UIColorItem_ChooseColor(object sender, Color color)
        {
            try
            {
                Setting.Theme.BackColor = color;
                ThemHelper.SetSystemThem();
                this.txtCustomBackColorRGB.Text = $"{color.R},{color.G},{color.B}";
                this.txtCustomBackColorARGB.Text = color.ToString().Replace("Color [", "").Replace("]", "");
                this.txtCustomBackColorHTML.Text = color.ToHTML();
                this.txtCustomBackColorCode.Text = color.Name;
            }
            catch (Exception ex)
            {
                this.ShowWarningNotifier(ex.Message);
            }
        }

        /// <summary>
        /// 预定义颜色和中国传统颜色选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UIButton_MouseClick(object sender, MouseEventArgs e)
        {
            if (sender is UIButton uIButton)
            {
                ThemItem themItem = uIButton.Tag as ThemItem;

                //保存主题配置到配置文件
                Setting.Theme.BackColor = themItem.BackColor;
                Setting.Theme.ForeColor = themItem.ForeColor;
                ThemHelper.SetSystemThem();
                this.uIColorItem.SelectedColor = themItem.BackColor;
            }
        }

        /// <summary>
        /// 随机颜色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRandomColor_Click(object sender, EventArgs e)
        {
            //生成随机颜色
            Color randomColor = ColorHelper.GetRandomColor(false);

            this.uIColorItem.SelectedColor = randomColor;

            this.btnRandomColor.FillColor = randomColor;
            this.btnRandomColor.FillColor2 = randomColor;
            this.btnRandomColor.FillHoverColor = randomColor;
            this.btnRandomColor.FillPressColor = randomColor;
            this.btnRandomColor.FillSelectedColor = randomColor;
            this.btnRandomColor.RectColor = randomColor;
            this.btnRandomColor.RectHoverColor = randomColor;
            this.btnRandomColor.RectPressColor = randomColor;
            this.btnRandomColor.RectSelectedColor = randomColor;
            this.btnRandomColor.TipsColor = randomColor;

            Setting.Theme.BackColor = randomColor;
            ThemHelper.SetSystemThem();
        }

        /// <summary>
        /// RGB转换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConvertToRGB_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtConvertToRGB.Text))
            {
                this.ShowWarningNotifier("请输入RGB代码");
                return;
            }
            var rgbs = this.txtConvertToRGB.Text.Split(',');
            if (rgbs == null || rgbs.Length != 3)
            {
                this.ShowWarningNotifier("输入的RGB代码不正确。格式应为：255,255,255");
                return;
            }

            int red = Convert.ToInt32((rgbs[0]).Trim());
            int green = Convert.ToInt32((rgbs[1]).Trim());
            int blue = Convert.ToInt32((rgbs[2]).Trim());
            Color color = Color.FromArgb(red, green, blue);

            SetCustomColor(color);

        }

        /// <summary>
        /// 16进制HTML颜色转换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConvertToHTML_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtConvertToHTML.Text))
            {
                this.ShowWarningNotifier("请输入HTML颜色代码");
                return;
            }

            if (!this.txtConvertToHTML.Text.Contains("#"))
            {
                this.ShowWarningNotifier("输入的HTML颜色代码不正确。格式应为：#CD5C5C");
                return;
            }
            Color color = ColorHelper.ToColor(this.txtConvertToHTML.Text);

            SetCustomColor(color);
        }


        /// <summary>
        /// 字体颜色选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="value"></param>
        private void uiColorPickerForeColor_ValueChanged(object sender, Color value)
        {
            Setting.Theme.ForeColor = value;
            ThemHelper.SetSystemThem();
        }

        /// <summary>
        /// 鼠标移过 预定义颜色和中国传统颜色按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UIButton_MouseEnter(object sender, EventArgs e)
        {
            if (sender is UIButton uIButton)
            {
                uIButton.Size = new Size(uIButton.Width + 10, uIButton.Height + 10);
                uIButton.Font = new Font("宋体", 13f, FontStyle.Bold);
            }
        }

        /// <summary>
        /// 鼠标移出 预定义颜色和中国传统颜色按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UIButton_MouseLeave(object sender, EventArgs e)
        {
            if (sender is UIButton uIButton)
            {
                uIButton.Size = this.btnRandomColor.Size;
                uIButton.Font = new Font("宋体", 10.5f);
            }
        }

        private void SetCustomColor(Color color)
        {
            try
            {
                Setting.Theme.BackColor = color;
                ThemHelper.SetSystemThem();
                this.txtCustomBackColorRGB.Text = $"{color.R},{color.G},{color.B}";
                this.txtCustomBackColorARGB.Text = color.ToString().Replace("Color [", "").Replace("]", "");
                this.txtCustomBackColorHTML.Text = color.ToHTML();
                this.txtCustomBackColorCode.Text = color.Name;
            }
            catch (Exception ex)
            {
                this.ShowWarningNotifier(ex.Message);
            }
        }


        /// <summary>
        /// 设置字体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSetFont_Click(object sender, EventArgs e)
        {
            UIStyles.DPIScale = true;
            UIStyles.GlobalFont = true;
            UIStyles.GlobalFontName = this.cbFont.SelectedItem.ToString();
            UIStyles.GlobalFontScale = this.uiTrackBarFontScale.Value;
            UIStyles.SetDPIScale();

            Setting.Theme.FontFamily = this.cbFont.SelectedItem.ToString();
            Setting.Theme.FontSize = this.uiTrackBarFontScale.Value;
        }

        private void uiTrackBarFontScale_ValueChanged(object sender, EventArgs e)
        {
            this.lblFontScale.Text = this.uiTrackBarFontScale.Value.ToString();
        }

        /// <summary>
        /// 主题颜色项
        /// </summary>
        private class ThemItem
        {
            public ThemItem(string colorName, Color backColor)
            {
                this.ColorName = colorName;
                this.BackColor = backColor;
            }

            public ThemItem(string colorName, Color backColor, Color foreColor)
            {
                this.ColorName = colorName;
                this.BackColor = backColor;
                this.ForeColor = foreColor;
            }

            public ThemItem(string colorName, Color backColor, string group, string tips)
            {
                this.ColorName = colorName;
                this.BackColor = backColor;
                this.Group = group;
                this.Tips = tips;
            }

            public ThemItem(string colorName, Color backColor, string group, string tips, Color foreColor)
            {
                this.ColorName = colorName;
                this.BackColor = backColor;
                this.Group = group;
                this.Tips = tips;
                this.ForeColor = foreColor;
            }

            /// <summary>
            /// 颜色名称
            /// </summary>
            public string ColorName { get; set; }

            /// <summary>
            /// 背景颜色
            /// </summary>
            public Color BackColor { get; set; }

            /// <summary>
            /// 字体颜色
            /// </summary>
            public Color ForeColor { get; set; } = Color.White;

            /// <summary>
            /// 分组
            /// </summary>
            public string Group { get; set; }

            /// <summary>
            /// 提示文字
            /// </summary>
            public string Tips { get; set; }
        }


        private void cbControlThemColor_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbControlThemColor.ContainsFocus)
            {
                UIMenuStyle uIMenuStyle = (UIMenuStyle)cbControlThemColor.SelectedValue;
                Setting.Theme.ControlThemColor = uIMenuStyle;

                switch (uIMenuStyle)
                {
                    case UIMenuStyle.Black:

                        break;
                    case UIMenuStyle.White:

                        break;
                }

                ThemHelper.SetSystemThem();
            }
        }

        private void btnWindowsOk_Click(object sender, EventArgs e)
        {
            Screen mainScreen = Screen.PrimaryScreen;
            Rectangle workingArea = mainScreen.WorkingArea;

            if (this.txtWindowsWidth.IntValue > workingArea.Width)
            {
                this.ShowWarningNotifier($"窗口宽度最大只能{workingArea.Width}");
                this.txtWindowsWidth.IntValue = workingArea.Width;
                GlobalData.MainForm.WindowState = FormWindowState.Maximized;
                return;
            }
            if (this.txtWindowsWidth.IntValue < GlobalData.MainForm.MinimumSize.Width)
            {
                this.ShowWarningNotifier($"窗口宽度最小只能{GlobalData.MainForm.MinimumSize.Width}");
                this.txtWindowsWidth.IntValue = GlobalData.MainForm.MinimumSize.Width;
                return;
            }

            if (this.txtWindowsHeight.IntValue > workingArea.Height)
            {
                this.ShowWarningNotifier($"窗口高度最大只能{workingArea.Height}");
                this.txtWindowsHeight.IntValue = workingArea.Height;
                GlobalData.MainForm.WindowState = FormWindowState.Maximized;
                return;
            }
            if (this.txtWindowsHeight.IntValue < GlobalData.MainForm.MinimumSize.Height)
            {
                this.ShowWarningNotifier($"窗口高度最小只能{GlobalData.MainForm.MinimumSize.Height}");
                this.txtWindowsHeight.IntValue = GlobalData.MainForm.MinimumSize.Height;
                return;
            }

            GlobalData.MainForm.Size = new Size(this.txtWindowsWidth.IntValue, this.txtWindowsHeight.IntValue);
        }
    }
}
